package com.springapp.mvc.db.DAO;

import com.springapp.mvc.db.entities.Person;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
//@Scope("session")
public class PersonDAO {

    private List<Person> personList;

    public PersonDAO (){
		System.out.println("Creating PersonDAO!!!");
        personList = new ArrayList<Person>();
		for(int i = 0; i < 125; i++) {
			personList.add(new Person("Grisha", i))
		}
	}

    public List<Person> findAll() {

        return personList;
    }


    public void delete(Person person){
        personList.remove(person);
    }

    public void add(Person person) {
        personList.add(person);
    }

    public Person getById(int id){
        return personList.get(id);
    }

}
